home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!mcnc!rutgers!tut.cis.ohio-state.edu!cwjcc!hal!ncoast!allbery
- From: geoff@p.UUCP (Geoff Leach)
- Newsgroups: comp.sources.misc
- Subject: v04i017: termlist: a perl program to print termcap entries
- Message-ID: <8808081802.AA21532@pyramid.pyramid.com>
- Date: 7 Aug 88 16:43:00 GMT
- Sender: allbery@ncoast.UUCP
- Reply-To: geoff@p.UUCP (Geoff Leach)
- Lines: 405
- Approved: allbery@ncoast.UUCP
-
- Posting-number: Volume 4, Issue 17
- Submitted-by: "Geoff Leach" <geoff@p.UUCP>
- Archive-name: termlist
-
- Termlist is a perl program that produces an annotated listing of
- termcap file entries. The output is (to the author, at least) more
- comprehensible than the standard termcap entry.
-
- Thanks to Larry Wall for making it possible!
- --- Attached File ---
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of shell archive."
- # Contents: README termlist termlist.pl
- # Wrapped by geoff@laticorp on Sun Aug 7 12:13:06 1988
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(753 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- X Termlist.pl is a perl program that reads selected entries
- X (or all entries) from a termcap file and prints a sorted,
- X annotated list of the entries, one per line. The annotations
- X file may be augmented to reflect capabilities in local use.
- X The termlist file has one entry per line:
- X capability <tab> description
- X Limes beginning with a "#" are ignored. There is no line
- X continuation.
- X
- X There are two paths in termlist.pl, /usr/local/bin/perl
- X and /usr/local/lib/termlist.
- X
- X To install, simply copy termlist to /usr/local/lib and
- X termlist.pl to /usr/local/bin, or whereever you prefer.
- X
- X To run: termlist.pl < termcap_file [entries]. If [entries] is
- X empty, the entire termcap_file is printed.
- X
- X Termlist was developed under perl version 2.0
- END_OF_FILE
- if test 753 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'termlist' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'termlist'\"
- else
- echo shar: Extracting \"'termlist'\" \(5448 characters\)
- sed "s/^X//" >'termlist' <<'END_OF_FILE'
- X# Sources
- X# Termcap Reference Manual:
- X# D. R. Merritt, Inter'l Technical Seminars, San Francisco CA
- X# Termcap:
- X# R. M. Stallman, Free Software Foundation, Cambridge MA
- X# Termcap(5)
- X# BSC 4.2 distribution termcap(5)
- X# BSC 4.3 distribution termcap(5)
- X# Sun OS 3.4 termcap(5)
- Xae end alternate character set
- Xal add blank line before cursor
- XAL add 'n' blank lines before cursor
- Xam auto margin
- Xas start alternate character set
- Xbc backspace character
- Xbl bell
- Xbs backspace
- Xbt backtab
- Xbw backspace wraps
- XCC command character in prototype
- Xcd clear to end of display
- Xce clear to end of line
- Xch cursor horizontal
- Xcl clear screen
- Xcm cursor motion
- XCM cursor motion, relative to memory display
- Xco number of columns
- Xcr carriage return
- Xcs change scroll
- XcS change scroll (alternate form)
- XCs default command in menu line (Contest DOS color)
- Xct clear all tab stops
- Xcv cursor vertical
- Xda display retained above
- Xdb display retained below
- XdB delay for backspace
- Xdc delete character
- XdC delay for carriage
- XdF delay for formfeed
- Xdl delete line
- XDL delete 'n' lines sarting at cursor
- Xdm delete mode
- XdN delay for newline
- Xdo down line
- XDO move cursor vertically down 'n' lilnes
- Xds disable display of status line
- XdT delay for tab
- Xec clear 'n' characters at cursor
- Xed end delete mode
- Xei erases oversrike
- Xeo output of space ends overstrike
- XEP even parity
- Xes other display commands work while writing status line
- Xff formfeed
- Xfs move cursor into status line
- Xgn terminal type is generic
- Xhc hardcopy
- Xhd half line down
- XHD half duplex
- Xho cursor home
- Xhs terminal has status line
- Xhu half line up
- Xhz terminal cannot accept '~' as output
- Xi1 initialize terminal for each login session (terminfo)
- Xi2 initialize terminal for each login session (terminfo)
- Xi3 initialize terminal for each login session (terminfo)
- Xic insert characer
- XIC insert 'n' characters at cursor
- Xif initialization file
- Xim insert mode
- Xin inserts null
- Xip insert pad
- XiP pathname of initialization program (terminfo)
- Xis initialization string
- Xit initial spacing between hardware tab stops
- Xk0 keypad 0 (or 10)
- Xk1 keypad 1
- Xk2 keypad 2
- Xk3 keypad 3
- Xk4 keypad 4
- Xk5 keypad 5
- Xk6 keypad 6
- Xk7 keypad 7
- Xk8 keypad 8
- Xk9 keypad 9
- XK1 keypad upper left
- XK2 keypad upper right
- XK3 keypad center
- XK4 keypad lower left
- XK5 keypad lower right
- Xka clear all tabs key
- XkA insert line key
- Xkb keypad backspace
- XkC clear screen key
- Xkd keypad down
- XkD delete character key
- Xke keypad end
- XkE clear to end of line key
- XkF scroll forward key
- Xkh keypad home
- XkH home down key
- XkI insert character key
- Xki keypad left
- XkL delete line key
- Xkl keypad left
- XkL delete line key
- Xkm terminal has meta key
- XkM exit insert mode key
- Xkn keypad number
- XkN next page key
- Xko non-function keys
- XkP previous page key
- Xkr keypad right
- XkR scroll reverse key
- Xks keypad start
- XkS clear to end of screen key
- Xkt clear tab stop this column key
- XkT set tab stop this column
- Xku keypad up
- Xkx cancel command
- Xl0 label on "other" function key
- Xl1 label on "other" function key
- Xl2 label on "other" function key
- Xl3 label on "other" function key
- Xl4 label on "other" function key
- Xl5 label on "other" function key
- Xl6 label on "other" function key
- Xl7 label on "other" function key
- Xl8 label on "other" function key
- Xl9 label on "other" function key
- XLC lower case only
- Xle move cursor left one column
- XLE move cursor left 'n' columns
- Xli number of lines
- Xll last line
- Xma arrow key map
- Xmb enter blinking mode
- Xmd enter double-bright mode
- Xme turn off all appearance modes
- Xmh enter half-bright mode
- Xmi move insert
- Xml memory lock on move insert cursor
- Xmk enter invisible mode
- Xmm enable meta key
- Xmo disable meta key
- Xmp enter protected mode
- Xmr enter reverse video mode
- Xms move standout
- Xmu memory unlock on move insert cursor
- Xnc no carriage return
- Xnd non-desructive space
- Xnl new line
- Xns no scrolling
- Xnv move to next line (may clear remainder of current line)
- Xok command completion
- XOP odd parity
- Xos overstrikes
- Xpb lowest baud rate requiring padding
- Xpc pad characer
- Xpf terminate redirection to attached printer
- Xpk program function key n to type string s (terminfo)
- Xpk program function key n to execute string s (terminfo)
- Xpo redirect output to printer
- XpO redirect 'n' characters to printer
- Xps print screen to attached printer
- Xpt performs tab
- Xpx program function key n to transmit string s (terminfo)
- Xr1 reset terminal to sane modes (terminfo)
- Xr2 reset terminal to sane modes (terminfo)
- Xr3 reset terminal to sane modes (terminfo)
- Xrc move to saved cursor position
- Xrf reset file (like if, but for reset(1))
- XRI move cursor right 'n' columns
- Xrp output character repeated 'n' times
- Xrs reset terminal modes (like is, but fore reset(1))
- Xsa turn on appearance modes
- Xsc save cursos position
- Xse standout end
- Xsf scroll forwards
- XSF scroll up 'n' lines
- Xsg number of blank characters left by so or se
- Xso standout
- Xsr scroll down
- XSR scroll down 'n' lines
- Xst set tab stop at cursor
- Xta tab
- Xtc copy this entry
- Xte termcap end
- Xti termcap initialization
- Xts move cursor to status line
- Xuc underscore one character and move past it
- Xue underscore end
- Xug underscore garbage
- Xul underline
- Xup up line
- XUP move cursor up 'n' lines
- Xus underscore start
- Xvb visual bell
- Xve visual mode end
- Xvi cursor invisible mode
- Xvs visual mode start
- Xvt virtual terminal number
- Xwi set output screen window
- Xws width of status line
- Xxb Behive (f1 = ESC, f2 = ^C)
- Xxn newline ignored after wrap (Concept)
- Xxr return acts like \r\n (Delta Data)
- Xxs standout not erased by writing over it (HP 264?)
- Xxt tabs not destructive, magic so character (Teleray 1061)
- Xxx Tektronix 4025 insert line
- END_OF_FILE
- if test 5448 -ne `wc -c <'termlist'`; then
- echo shar: \"'termlist'\" unpacked with wrong size!
- fi
- # end of 'termlist'
- fi
- if test -f 'termlist.pl' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'termlist.pl'\"
- else
- echo shar: Extracting \"'termlist.pl'\" \(3196 characters\)
- sed "s/^X//" >'termlist.pl' <<'END_OF_FILE'
- X#! /usr/local/bin/perl
- X
- X# Save the ARGV list; if non-null, its a list of term entryies
- X$args = $#ARGV + 1;
- Xwhile ( $ARGV[0] )
- X{
- X $argv{$ARGV[0]} = 1;
- X shift(@ARGV);
- X}
- X
- X# Process the list of known termcap identifiers and their description
- X
- Xopen(termlist, "/usr/local/lib/termlist");
- Xwhile (<termlist>)
- X{
- X chop;
- X @line = split(/\t/);
- X $symbol_definitions{$line[0]} = $line[1] if !/^#/;
- X}
- Xclose(termlist);
- X
- X# process the termcap file presented on stdin
- X
- Xwhile ( <> )
- X{
- X $comments = "";
- X $namelist = "";
- X # Dispose of the coments (if any)
- X while ( /^#|^\n/ )
- X {
- X $comments .= length($_) <= 70 ? $_ : substr($_, 0, 70) . "...\n";
- X $_ = <>;
- X }
- X
- X # Get the entire entry
- X $entry = $_;
- X do
- X {
- X $entry .= <>;
- X } while substr($entry, length($entry)-2, 1) eq "\\";
- X
- X # If the file had trailing comments we will have read a null entry
- X exit if !$entry;
- X
- X # Clear leading whitespace and (possibly escaped) newlines,
- X # using the multiple line record matching feature.
- X $* = 1; $entry =~ s/\t|^ +|\\\n|\n//g; $* = 0;
- X
- X # Get the terminal names, delimited by "|", ended by ":"
- X # and the capabilities, enclosed in one or more ":", being careful to
- X # avoid being confused by escaped colons and escaped backslashes at the
- X # end of an entry.
- X $entry =~ s/\\:/\\\001/g;
- X $entry =~ s/\\\\/\\\002/g;
- X @names = split(/:+/, $entry);
- X
- X # Look for a particular terminal if any were specified. Otherwise do all.
- X $found = 0;
- X foreach $name ( split(/\|/, $names[0]) )
- X {
- X $found |= $argv{$name};
- X $namelist .= " " . $name . "\n";
- X }
- X
- X # Loop to the next entry if a requested entry was not found.
- X next if $args && !$found;
- X
- X # Print that part of the entry which we've saved waiting to see if
- X # the entry would be selected.
- X print $comments, "Names for this terminal:\n", $namelist,
- X "\nTerminal capabilities:\n";
- X
- X # Discard the first of the names entry, which contains the terminal names.
- X shift(@names);
- X
- X # Clear the symbol tables
- X @syms = ();
- X @symtab = ();
- X
- X # Translate some of the more obscure things in the capability definitions
- X # to "readable" definitions. The order of the first five is important.
- X foreach $nam ( @names )
- X {
- X ($name, $value) = split(/=|#/, $nam);
- X next if $name eq " ";
- X $value =~ s/\\\^/^/g;
- X $value =~ s/\\0x/0x/g;
- X $value =~ s/\\\001/:/g;
- X $value =~ s/\\\002/\\/g;
- X $value =~ s/\\\\/\\/g;
- X $value =~ s/\\b/<bs>/g;
- X $value =~ s/\\f/<ff>/g;
- X $value =~ s/\\n/<nl>/g;
- X $value =~ s/\\E/<esc>/g;
- X $value =~ s/\\1/01/g;
- X $value =~ s/\\2/02/g;
- X $value =~ s/\\3/03/g;
- X $value =~ s/\\4/04/g;
- X $value =~ s/\\5/05/g;
- X $value =~ s/\\6/06/g;
- X $value =~ s/\\7/07/g;
- X $value =~ s/\\0/<nul>/g;
- X $value =~ s/\\r/<ret>/g;
- X $value =~ s/\\t/<tab>/g;
- X $symtab{$name} = $value ? $value : "<set>";
- X push(@syms, $name);
- X }
- X format stdout =
- X @<<<<<<< @<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- X $sym $symtab_entry $symbol_def
- X.
- X foreach $sym ( sort @syms )
- X {
- X $symtab_entry = $symtab{$sym};
- X $symbol_def = $symbol_definitions{$sym};
- X $symbol_def = "" if $symbol_def eq "0";
- X write();
- X }
- X print "\f\n";
- X}
- END_OF_FILE
- if test 3196 -ne `wc -c <'termlist.pl'`; then
- echo shar: \"'termlist.pl'\" unpacked with wrong size!
- fi
- chmod +x 'termlist.pl'
- # end of 'termlist.pl'
- fi
- echo shar: End of shell archive.
- exit 0
-